/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cabarrus.xltosql.util;

import java.util.ArrayList;
import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;

/**
 *
 * @author moscac
 */
public class DBTypes {

    public DBTypes() {
        dbTypes.add(new DBType(java.sql.Types.VARCHAR, "Varchar"));
        dbTypes.add(new DBType(java.sql.Types.INTEGER, "Integer"));
        dbTypes.add(new DBType(java.sql.Types.FLOAT, "Float"));
        dbTypes.add(new DBType(java.sql.Types.DATE, "Date"));
        dbTypes.add(new DBType(java.sql.Types.TIMESTAMP, "Timestamp"));
        dbTypes.add(new DBType(java.sql.Types.BLOB, "BLOB"));
    }

    public void removeAll() {
        dbTypes.removeAll(dbTypes);
    }
    
    public ObservableList<DBType> getDbTypes() {
        return dbTypes;
    }

    public void setDbTypes(ObservableList<DBType> dbTypes) {
        this.dbTypes = dbTypes;
    }

    public int getDbType(String dbTypeName) {
        for (int i = 0; i < dbTypes.size(); i++) {
            if (dbTypeName.equals(dbTypes.get(i).getDbTypeName())) {
                return dbTypes.get(i).getDbType();
            }
        }
        return -1;
    }
    public String getDbTypeName(int dbType) {
        for (int i = 0; i < dbTypes.size(); i++) {
            if (dbType == dbTypes.get(i).getDbType()) {
                return dbTypes.get(i).getDbTypeName();
            }
        }
        return "";
    }
    private ObservableList<DBType> dbTypes = ObservableCollections.observableList(new ArrayList<DBType>(0));

}
